package com.yhk.wuchat.common.user.domain.enums;

/**
 * @version 1.0
 * @Author moresuo
 * @Date 2024/4/17 21:03
 * @注释
 */

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * 用户身份权限枚举
 */
@Getter
@AllArgsConstructor
public enum RoleEnum {
    ADMIN(1l,"超级管理员"),
    CHAT_MANAGER(2l,"群聊管理员");
    private final Long id;
    private final String desc;

    private static Map<Long,RoleEnum> cache;
    static{
        cache= Arrays.stream(RoleEnum.values()).collect(Collectors.toMap(RoleEnum::getId,Function.identity()));
    }
    public static RoleEnum of(Long id){
        return cache.get(id);
    }
}
